<?php
pcntl_signal(SIGCHLD,function ($signo){
   fprintf(STDOUT,"pid=%d 接收到%d信号",posix_getpid(),$signo);
   $pid = pcntl_waitpid(-1,$status,WNOHANG);
   if ($pid>0){
       fprintf(STDOUT,"pid =%d退出了\n",$pid);
   }
});

$pid = pcntl_fork();
if ($pid>0){
    while (1){
        pcntl_signal_dispatch();
        fprintf(STDOUT,"pid=%d,ppid=%d,pgid=%d doing...\n",
            posix_getpid(),posix_getpid(),posix_getpgrp());
        sleep(1);
    }
}else{
    fprintf(STDOUT,"pid=%d child do...\n",posix_getpid());
    exit(10);
}